import numpy as np
import pandas as pd

import pygal

# 绘制雷达图
# 新型城镇化，生态环境，新型城镇化与生态环境-耦合度
zb_type = '生态环境'
# csh_file = '滇中县域-' + zb_type + '-综合评价得分-统一时序.xlsx'
csh_file = '滇中县域-新型城镇化与生态环境-协调度a2b2.xlsx'
title = '滇中县域-新型城镇化与生态环境协调度-时空演变-雷达图'
dataframe = pd.read_excel(csh_file, index_col=0)
print('-----------原始数据-----------')
print(dataframe)
county_names = np.array(dataframe.columns)
radar_chart = pygal.Radar()
radar_chart.title = title
radar_chart.x_labels = county_names
for i in dataframe.index:
    rowdata = np.array(dataframe.loc[i].values)
    print(rowdata)
    radar_chart.add(str(i), rowdata)
radar_chart.render_to_file(title + '.svg')
